package stemming;

import org.tartarus.snowball.SnowballProgram;

/**
 * The {@link SnowBallStemmer} is used to stem words using 
 * a {@link SnowballProgram}.
 */
public class SnowBallStemmer
{
  /** The stemming program used. */
  private SnowballProgram stemmerProgram;

  /**
   * Instantiates a new snow ball stemmer.
   *
   * @param stemmerProgram the stemmer program
   */
  public SnowBallStemmer(SnowballProgram stemmerProgram)
  {
    this.stemmerProgram = stemmerProgram;
  }
  
  /**
   * Stem a word using SnowBall stemming algorithm.
   *
   * @param wordToStem the word to stem
   * @return the stemmed word
   */
  public String stemAWord(String wordToStem)
  {
    stemmerProgram.setCurrent(wordToStem.toLowerCase().replace("\"", "").replace("'", ""));
    stemmerProgram.stem();
    return stemmerProgram.getCurrent().trim().toLowerCase();
  }
}
